import { TenantEntity } from "@/entities/TenantEntity";
import request from "../request";
import BusinessConstant from "@/constant/BusinessConstant";
// 路径前缀
const PREFIX = BusinessConstant.ROOT_SERVER + "/tenant";

export default class TenantApi {
  /**
   * 登录
   * @param phone 手机号
   * @param password 密码
   */
  static login(phone: string, password: string) {
    return request({
      method: "POST",
      url: `${PREFIX}/login`,
      data: {
        phone,
        password,
      },
    });
  }

  /**
   * 注册
   * @param phone 手机
   * @param password 密码
   */
  static registry(phone: string, password: string) {
    return request({
      method: "POST",
      url: `${PREFIX}/registry`,
      data: {
        phone,
        password,
      },
    });
  }

  /**
   * 获取租客信息
   */
  static getTenant() {
    return request({
      method: "GET",
      url: `${PREFIX}`,
    });
  }

  /**
   * 更新租客信息
   * @param data 需要更新的数据
   */
  static updateTenant(
    data: { name?: string; remark?: string } | TenantEntity.ITenantVerification
  ) {
    return request({
      method: "PUT",
      url: `${PREFIX}`,
      data,
    });
  }

  /**
   * 获取租客的租赁房屋
   * @param tenantId
   */
  static getTenantLeaseHouse(tenantId: number) {
    return request({
      method: "GET",
      url: `${PREFIX}/lease?tenantId=${tenantId}`,
    });
  }

  /**
   * 获取租客信息通过租客id列表
   * @param tenantIdList
   */
  static getTenantByIdList(tenantIdList: string) {
    return request({
      method: "GET",
      url: `${PREFIX}/list?tenantIdList=${tenantIdList}`,
    });
  }
}
